﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;

[assembly: WebResource("ESWebControls.Images.exclamation_red.jpg", "img/jpg")]
[assembly: WebResource("ESWebControls.Images.greencheck.jpg", "img/jpg")]
namespace ESWebControls
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:ValidationImage runat=server></{0}:ValidationImage>")]
    public class ValidationImage : Image
    {
        private bool _validated = false;

        protected override void OnInit(EventArgs e)
        {
            Visible = false;
            ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "ESWebControls.Images.exclamation_red.jpg");
            base.OnInit(e);
        }

        public bool Validated
        {
            get
            {
                return _validated;
            }
            set
            {
                _validated = value;
                Visible = true;
                if (value)
                    ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "ESWebControls.Images.greencheck.jpg");
                else
                    ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "ESWebControls.Images.exclamation_red.jpg");
            }
        }
    }
}
